<template>
  <div>
    <div class="box" v-show="show">
      <div class="con">
        <div class="q1">
          <h3>{{ title }}</h3>
          <button @click="close" class="btn">x</button>
        </div>
        <div class="q1">{{ content }}</div>
        <div class="q1">
          <button @click="onconfirm" class="button">确定</button
          ><button @click="oncancel" class="button">取消</button>
        </div>
      </div>
    </div>
  </div>
</template>
<script>
export default {
  data() {
    return {
      show: false,
      title: "默认标题",
      content: "默认内容",
      confirm: () => {},
      cancel: () => {},
    };
  },
  methods: {
    close() {
      this.show = false;
    },
    onconfirm() {
      this.confirm();
      this.close();
    },
    oncancel() {
      this.cancel();
      this.close();
    },
  },
};
</script>
<style scoped>
* {
  margin: 0;
  padding: 0;
}
.box {
  width: 100vw;
  height: 100vh;
  position: fixed;
  top: 0px;
  left: 0px;
  background: rgba(0, 0, 0, 0.3);
  display: flex;
  justify-content: center;
  align-items: center;
}
.con {
  width: 260px;
  height: 160px;
  background: #fff;
  border-radius: 8px;
}
.q1 {
  width: 220px;
  height: 40px;
  margin: 10px 20px;
  line-height: 40px;
}
button {
  border: none;
}
.btn {
  float: right;
  margin-top: -30px;
  margin-right: 10px;
  width: 18px;
  height: 18px;
}
.button {
  float: right;
  margin-right: 10px;
  margin-top: 10px;
  width: 50px;
  height: 30px;
}
</style>